<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let obj = {
            name: "twj"
        }
        //obj = null
        // let s1 = new Set()
        // s1.add(obj)
        // s1.add("aaa")
        // obj=null

        /*
            1. 只能保存复杂类型
            2. 不存在引用计数+1
            3. size、for不能用了，因为值已经不确定了
        */
        let s1 = new WeakSet()
        s1.add(obj)
        console.log(s1)
        obj = null
        console.log(s1)

    </script>
</body>

</html>